<?php

use think\facade\Route;

Route::rest([
    'index'   => ['GET', '', 'list'],
    'read' => ['GET', '/:id', 'detail'],
    'save' => ['POST', '', 'add'],
    'update' => ['PUT', '/:id', 'edit'],
    'delete' => ['DELETE', '/:id', 'delete'],
]);

Route::group('admin', function () {
    // 初始化客服
    Route::get('index/init', 'admin.Index/init')->name('chat.admin.index.init');

    // 获取客服 select 列表
    Route::get('customerService/select', 'admin.CustomerService/select')->name('chat.admin.customerService.select');

    Route::group(function () {
        // 修改客服配置
        Route::any('config/basic', 'admin.config/basic')->name('chat.admin.config.basic');
        Route::any('config/system', 'admin.config/system')->name('chat.admin.config.system');
        Route::any('config/application', 'admin.config/application')->name('chat.admin.config.application');

        // 快捷回复
        Route::resource('commonWord', 'admin.CommonWord');

        // 常见问题
        Route::resource('question', 'admin.Question');

        // 客服管理
        Route::resource('customerService', 'admin.CustomerService');

        // 会话管理
        Route::get('user', 'admin.User/list')->name('chat.admin.user.list');
        Route::delete('user/:id', 'admin.User/delete')->name('chat.admin.user.delete');
        
        // 聊天记录管理
        Route::get('record', 'admin.Record/list')->name('chat.admin.record.list');
    })->middleware('check_rule', 'admin');

})->middleware('check_login', 'admin');
